package com.maluxinyu.easyretry.service;

import org.springframework.stereotype.Component;

import com.aizuda.easy.retry.client.core.retryer.EasyRetryTemplate;
import com.aizuda.easy.retry.client.core.retryer.RetryTaskTemplateBuilder;
import com.maluxinyu.easyretry.executor.MyExecutorTask;
import com.maluxinyu.easyretry.vo.OrderVo;

/**
 * easy-retry中的手动重试
 */
@Component
public class ExecutorMethodService {

    public void myExecutorMethod(){
        OrderVo orderVo = OrderVo.builder()
                .orderId("123456789")
                .source(1)
                .build();
        EasyRetryTemplate easyRetryTemplate = RetryTaskTemplateBuilder.newBuilder()
                // 手动指定场景名称
                .withScene(MyExecutorTask.SCENE)
                // 指定要执行的任务
                .withExecutorMethod(MyExecutorTask.class)
                // 指定参数
                .withParam(orderVo)
                .build();
        // 执行模板
        easyRetryTemplate.executeRetry();
    }

}
